package com.example.kotlindemo

import android.util.Log
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel

/**
 *@time : 2021/3/14
 *@author :muzi102
 *@Description
 */
public class MyViewModel : ViewModel() {
    var result = MutableLiveData<Int>()

    public fun addNumber() {
        if (result.value == null) {
            result.value = 0
        }
        result.value = result.value!! + 2
        Log.e("MyViewModel","点击了 addNumber")
    }

    public fun subNumber() {
        if (result.value == null) {
            result.value = 0
        }
        result.value = result.value!! - 2
        Log.e("MyViewModel","点击了 subNumber")

    }
}